package com.itheima.web.controller.stat;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.service.cargo.ContractProductService;
import com.itheima.service.system.SysLogService;
import com.itheima.web.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;

@RequestMapping("stat")
@Controller
public class StatController extends BaseController{
    @Reference
    ContractProductService contractProductService;
    @Autowired
    SysLogService sysLogService;

    @RequestMapping("toCharts")
    public String toCharts(String chartsType){
        return "stat/stat-"+chartsType;
    }

    @RequestMapping("getSellData")
    public @ResponseBody List getSellData(){
        //此方法统计产品的销售情况
        List allSell = contractProductService.getSellData(getCurrentUser().getCompanyId());
        return allSell;
    }

    @RequestMapping("getFactoryData")
    public @ResponseBody List getFactoryData(){
        //此方法统计生产厂家的销售情况
        List allFactoryData=contractProductService.getFactorySellData(getCurrentUser().getCompanyId());
        return allFactoryData;
    }

    @RequestMapping("getOnlineData")
    public @ResponseBody List getOnlineData(){
        //判断在什么时候访问的此数多
        List allOnlineData=sysLogService.getOnlineData();
        return allOnlineData;
    }
}
